<?php

define('ROOT', dirname(dirname(__FILE__)));
define('DS', DIRECTORY_SEPARATOR);
define('LIB', ROOT . DS . 'mithos' . DS);
define('SMARTY_DIR', ROOT . DS . 'smarty' . DS);

function underscore($string = '') {
	return strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $string));
}

function pr($data = '') {
    echo '<pre>' . print_r($data, true) . '</pre>';
}

function is_ajax() {
	return array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
}

function loader($classname) {
	$classname = underscore($classname);
	if (file_exists(LIB . $classname . '.php')) {
		require_once LIB . $classname . '.php';
	}
}

require_once SMARTY_DIR . 'Smarty.class.php';

spl_autoload_register('loader');

?>